home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / Applications (app) / Earth Plot / ep.setColors.c < prev    next >
C/C++ Source or Header  |  1987-07-18  |  2KB  |  108 lines

  1. #include "ep.const.h"
  2. #include "ep.extern.h"
  3. #include "DialogMgr.h"
  4.  
  5. setColors()
  6. {
  7.     DialogPtr    colorsDialogPtr;
  8.     int            itemHit;
  9.     Rect    junkRect;
  10.     int        tempKind;
  11.  
  12. ControlHandle
  13.     backgroundButton,        /* colors dialog items */
  14.     earthbackgroundButton,
  15.     earthoutlineButton,
  16.     latButton,
  17.     longButton,
  18.     landmassButton,
  19.     
  20.     IButton[6],
  21.     CButton[8];
  22.  
  23. int        i,
  24.         currentC;
  25. long    c[8],
  26.         t[6];        /* colors temp storage */
  27.  
  28. int    currentT;
  29.  
  30.     c[0] = blackColor;
  31.     c[1] = whiteColor;
  32.     c[2] = redColor;
  33.     c[3] = greenColor;
  34.     c[4] = blueColor;
  35.     c[5] = cyanColor;
  36.     c[6] = magentaColor;
  37.     c[7] = yellowColor;
  38.  
  39.     t[0] = backgroundC;
  40.     t[1] = earthbackgroundC;
  41.     t[2] = earthoutlineC;
  42.     t[3] = latC;
  43.     t[4] = longC;
  44.     t[5] = landC;
  45.  
  46.     colorsDialogPtr = GetNewDialog (300, 0L, (long) -1);
  47.     GetDItem(colorsDialogPtr,11,&tempKind,&IButton[0],&junkRect);
  48.     GetDItem(colorsDialogPtr,12,&tempKind,&IButton[1],&junkRect);
  49.     GetDItem(colorsDialogPtr,13,&tempKind,&IButton[2],&junkRect);
  50.     GetDItem(colorsDialogPtr,14,&tempKind,&IButton[3],&junkRect);
  51.     GetDItem(colorsDialogPtr,15,&tempKind,&IButton[4],&junkRect);
  52.     GetDItem(colorsDialogPtr,16,&tempKind,&IButton[5],&junkRect);
  53.     GetDItem(colorsDialogPtr,3,&tempKind,&CButton[0],&junkRect);
  54.     GetDItem(colorsDialogPtr,4,&tempKind,&CButton[1],&junkRect);
  55.     GetDItem(colorsDialogPtr,5,&tempKind,&CButton[2],&junkRect);
  56.     GetDItem(colorsDialogPtr,6,&tempKind,&CButton[3],&junkRect);
  57.     GetDItem(colorsDialogPtr,7,&tempKind,&CButton[4],&junkRect);
  58.     GetDItem(colorsDialogPtr,8,&tempKind,&CButton[5],&junkRect);
  59.     GetDItem(colorsDialogPtr,9,&tempKind,&CButton[6],&junkRect);
  60.     GetDItem(colorsDialogPtr,10,&tempKind,&CButton[7],&junkRect);
  61.  
  62.     currentT = 0;
  63.  
  64.     do {
  65.         for (i=0;i<6;i++)
  66.             SetCtlValue(IButton[i],i == currentT);
  67.         
  68.         for (i=0;i<8;i++)
  69.             SetCtlValue(CButton[i],c[i] == t[currentT]);
  70.  
  71.         ModalDialog (0L, &itemHit);
  72.         
  73.         switch (itemHit) {
  74.         case 11:                /* "items" */
  75.         case 12:
  76.         case 13:
  77.         case 14:
  78.         case 15:
  79.         case 16:
  80.             currentT = itemHit - 11;
  81.             break;
  82.         case 3:
  83.         case 4:
  84.         case 5:
  85.         case 6:
  86.         case 7:
  87.         case 8:
  88.         case 9:
  89.         case 10:
  90.             t[currentT] = c[itemHit - 3];
  91.             break;
  92.         }
  93.     
  94.     } while ((itemHit != 1/* OK */) && (itemHit != 2/* CANCEL */));
  95.  
  96.     DisposDialog(colorsDialogPtr);
  97.  
  98.     if (itemHit == 1) {
  99.         backgroundC     = t[0];
  100.         earthbackgroundC= t[1];
  101.         earthoutlineC     = t[2];
  102.         latC             = t[3];
  103.         longC             = t[4];
  104.         landC             = t[5];
  105.     }
  106. }
  107.  
  108.